{extend name="layout:login" /}
{block name="main_content"}
  <!-- Login form -->
  <form id="model-form" class="sign-in form-horizontal shadow rounded no-overflow" action="" method="post">
    <div class="sign-header">
      <div class="form-group">
        <div class="sign-text">
          <span>用户登录</span>
        </div>
      </div><!-- /.form-group -->
    </div><!-- /.sign-header -->
    <div class="sign-body">
      <div class="form-group">
        <div class="input-group input-group-lg rounded no-overflow">
          <input type="text" class="form-control input-sm" placeholder="请输入手机号码" name="name" autocomplete="off" required>
          <span class="input-group-addon"><i class="fa fa-user"></i></span>
        </div>
      </div><!-- /.form-group -->
      <div class="form-group">
        <div class="input-group input-group-lg rounded no-overflow">
          <input type="password" class="form-control input-sm" placeholder="请输入登录密码" name="password" id="password">
          <span class="input-group-addon"><i class="fa fa-lock"></i></span>
        </div>
      </div><!-- /.form-group -->
      <div class="form-group">
        <button type="submit" class="btn btn-theme btn-lg btn-block no-margin rounded" id="login-btn">登录</button>
      </div><!-- /.form-group -->
    </div><!-- /.sign-body -->
    <div class="sign-footer">
      <div class="form-group">
        <div class="row">
          <div class="col-xs-6">
            <div class="ckbox ckbox-theme">
              <input id="is_remember" name="is_remember" type="checkbox">
              <label for="is_remember" class="rounded">记住密码</label>
            </div>
          </div>
          <div class="col-xs-6 text-right">
            <a class="sign-link" href="{:url('retrieve/index')}" title="lost password">忘记密码</a>
          </div>
        </div>
      </div><!-- /.form-group -->
    </div><!-- /.sign-footer -->
  </form><!-- /.form-horizontal -->
  <!--/ Login form -->

  <!-- Content text -->
  <p class="text-muted text-center sign-link">新用户<a href="{:url('register/index')}"> 立即注册</a></p>
  <!--/ Content text -->
{/block}
{block name="page_js"}
  <script src="{$site_root}/static/plugins/jquery-validate/jquery.validate.min.js"></script>
  <script src="{$site_root}/static/plugins/jquery-validate/bootstrap.validate.js"></script>
  <script type="text/javascript">
    var validator = $("form#model-form").validate({
      ignore: "",
      rules:{
        "name":{
          required: true,
          min: 13000000000,
          max: 19900000000
        },"password":{
          required: true
        }
      },
      messages:{
        "name":{
          required: "请输入手机号码",
          min: "用户手机号码不正确",
          max: "用户手机号码不正确",
        },"password":{
          required: "请输入登录密码"
        }
      },
      highlight:function(element) {
        $(element).parents('.form-group').addClass('has-error has-feedback');
      },
      unhighlight: function(element) {
        $(element).parents('.form-group').removeClass('has-error');
      },
      submitHandler: function(form){
        var $form = $(form);
        $.ajax({
          url: $form.attr("action"),
          type: $form.attr("method"),
          dataType: "JSON",
          data: $form.serialize(),
          success: function(data){
            if(data.code){
              location.href = data["url"];
            }else{
              alert(data["msg"]);
            }
          }, error: function () {
            alert("数据执行错误！");
          }
        });
      }
    });
  </script>
{/block}